#include "hoscrollwidget.h"

HoScrollWidget::HoScrollWidget(QWidget *parent)
    : QWidget{parent}
{
    this->area = new QScrollArea(parent);
    this->area->show();
    this->x = 0;
    this->y = 0;
    this->width = 0;
    this->height = 0;
    this->widget = nullptr;
}

HoScrollWidget::~HoScrollWidget() {
    if (this->widget != nullptr) {
        for (QWidget *w : this->widget->findChildren<QWidget*>()) {
            delete w;
        }
    }
    delete this->widget;
}

void HoScrollWidget::setPosSize(int x, int y, int width, int height) {
    this->x = x;
    this->y = y;
    this->width = width;
    this->height = height;
    this->area->setGeometry(x, y, width, height);
}

void HoScrollWidget::setWidget(QWidget *widget) {
    this->widget = widget;
    this->area->setWidget(this->widget);
}

void HoScrollWidget::setHorizontalScrollBarPolicy(Qt::ScrollBarPolicy policy) {
    this->area->setHorizontalScrollBarPolicy(policy);
}

void HoScrollWidget::setVerticalScrollBarPolicy(Qt::ScrollBarPolicy policy) {
    this->area->setVerticalScrollBarPolicy(policy);
}

int HoScrollWidget::getX() {
    return this->x;
}

int HoScrollWidget::getY() {
    return this->y;
}

int HoScrollWidget::getWidth() {
    return this->width;
}

int HoScrollWidget::getHeight() {
    return this->height;
}

QWidget* HoScrollWidget::getWidget() {
    return this->widget;
}
